/* Reset and base styles optimized for iframe and mobile-first design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Responsive container - adapts to iframe (450px) or full screen (90vh) */
.game-container {
    width: 100%;
    height: 450px; /* Default for iframe */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    position: relative;
    overflow: hidden;
}

/* Full screen detection for new tab */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Compact header design to save vertical space */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 50px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: help;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: scale(1.05);
}

.stat-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 16px;
    color: white;
    font-weight: bold;
    margin-top: 2px;
}

/* Main game area - flexible layout */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow: hidden;
}

/* Animal display section */
.animal-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}

.animal-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 3px solid #4facfe;
}

.animal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.animal-image {
    font-size: 48px;
    margin-bottom: 8px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.animal-name {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    text-transform: capitalize;
}

/* Classification buttons - optimized for touch and mouse */
.classification-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modified grid to accommodate 7 buttons instead of 6 */
.classification-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

/* Special styling for the 7th button to span full width */
.classification-btn:nth-child(7) {
    grid-column: 1 / -1;
}

.classification-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

/* Touch-friendly button sizing */
@media (max-width: 480px) {
    .classification-btn {
        min-height: 65px;
        padding: 10px 6px;
    }
}

.classification-btn:hover {
    border-color: #4facfe;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 172, 254, 0.3);
}

.classification-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.2);
}

.classification-btn.correct {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    border-color: #56ab2f;
    color: white;
    animation: correctPulse 0.6s ease;
}

.classification-btn.incorrect {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    border-color: #ff416c;
    color: white;
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.group-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.group-name {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

/* Special styling for the "other" category button text */
.classification-btn[data-group="other"] .group-name {
    font-size: 10px;
    line-height: 1.1;
}

/* Feedback section */
.feedback-section {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.feedback-message {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
}

.feedback-message.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-message.correct {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    color: white;
}

.feedback-message.incorrect {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
}

/* Game over screen */
.game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.game-over-screen.show {
    opacity: 1;
    visibility: visible;
}

.game-over-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

#gameOverTitle {
    color: #4facfe;
    margin-bottom: 20px;
    font-size: 24px;
}

.final-stats {
    margin-bottom: 20px;
}

.final-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px 0;
}

.final-label {
    font-weight: 500;
    color: #666;
}

.final-value {
    font-weight: bold;
    color: #333;
}

.play-again-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 172, 254, 0.4);
}

/* Tooltip for educational content */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    max-width: 200px;
    text-align: center;
    line-height: 1.3;
}

.tooltip.show {
    opacity: 1;
}

/* Responsive adjustments for mobile */
@media (max-width: 480px) {
    .game-header {
        padding: 6px 12px;
        min-height: 45px;
    }
    
    .stat-label {
        font-size: 9px;
    }
    
    .stat-value {
        font-size: 14px;
    }
    
    .game-area {
        padding: 12px;
        gap: 12px;
    }
    
    .animal-card {
        padding: 16px;
    }
    
    .animal-image {
        font-size: 40px;
    }
    
    .animal-name {
        font-size: 16px;
    }
    
    .classification-grid {
        gap: 8px;
    }
    
    .group-icon {
        font-size: 20px;
    }
    
    .group-name {
        font-size: 11px;
    }
    
    /* Adjust text size for "other" category on mobile */
    .classification-btn[data-group="other"] .group-name {
        font-size: 9px;
    }
}